package com.jzo2o.customer.service.impl;/**
 * @author wl
 * @version 1.0
 * @since 2025-09-17 17:00
 */

import cn.hutool.core.bean.BeanUtil;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.jzo2o.common.utils.UserContext;
import com.jzo2o.customer.mapper.BankMapper;
import com.jzo2o.customer.model.domain.BankAccount;
import com.jzo2o.customer.model.dto.request.BankAccountUpsertReqDTO;
import com.jzo2o.customer.model.dto.response.BankAccountResDTO;
import com.jzo2o.customer.service.IBankService;
import org.springframework.stereotype.Service;




/**
 * <p>
 * 银行实现类
 * </p>
 *
 * @author itcast
 * @since 2023-07-04
 */
@Service
public class BankServiceImpl extends ServiceImpl<BankMapper, BankAccount> implements IBankService {


    /**
     * 查询当前登录用户的银行账户信息
     *
     * @return
     */
    @Override
    public BankAccountResDTO queryCurrentUserBankAccount() {
        //查询当前登录用户的银行账户信息
        return BeanUtil.toBean(getById(UserContext.currentUserId()), BankAccountResDTO.class);
    }

    @Override
    public void saveBank(BankAccountUpsertReqDTO bankAccountUpsertReqDTO) {
        BankAccount bankAccount = BeanUtil.toBean(bankAccountUpsertReqDTO, BankAccount.class);
        bankAccount.setId(UserContext.currentUserId());
        saveOrUpdate(bankAccount);
    }
}
